import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 点检项设置信息 */
export interface EquipmentCheckType {
  id: number // id
  name?: string // 点检项名称
  status: number // 状态
  description: string // 描述
}

// 点检项设置 API
export const EquipmentCheckTypeApi = {
  // 查询点检项设置分页
  getEquipmentCheckTypePage: async (params: any) => {
    return await request.get({ url: `/business/equipment-check-type/page`, params })
  },

  // 查询点检项设置详情
  getEquipmentCheckType: async (id: number) => {
    return await request.get({ url: `/business/equipment-check-type/get?id=` + id })
  },

  // 新增点检项设置
  createEquipmentCheckType: async (data: EquipmentCheckType) => {
    return await request.post({ url: `/business/equipment-check-type/create`, data })
  },

  // 修改点检项设置
  updateEquipmentCheckType: async (data: EquipmentCheckType) => {
    return await request.put({ url: `/business/equipment-check-type/update`, data })
  },

  // 删除点检项设置
  deleteEquipmentCheckType: async (id: number) => {
    return await request.delete({ url: `/business/equipment-check-type/delete?id=` + id })
  },

  /** 批量删除点检项设置 */
  deleteEquipmentCheckTypeList: async (ids: number[]) => {
    return await request.delete({
      url: `/business/equipment-check-type/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出点检项设置 Excel
  exportEquipmentCheckType: async (params) => {
    return await request.download({ url: `/business/equipment-check-type/export-excel`, params })
  },

  // 查询所有保养类型 包含已绑定的和未绑定的
  getEquipmentCheckTypeMapList: async (params: any) => {
    return await request.get({ url: `/business/equipment-check-type/mapList`, params })
  },

  // 查询所有保养类型 包含已绑定的和未绑定的
  checkTypeMapList: async (params: any) => {
    return await request.get({ url: `/business/equipment-check-type/checkMapList`, params })
  },

  // 下载导入模板
  importTemplate: async () => {
    return request.download({ url: '/business/equipment-check-type/get-import-template' })
  }
}
